package com.three.controller;

import com.three.aop.LogAnotation;
import com.three.service.InventoryService;
import com.three.vo.AddInventoryVo;
import com.three.vo.BaoSunVo;
import com.three.vo.KeyboardVO;
import com.three.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 袁大毛
 * * @date 2024/10/25 下午7:06
 * @描述
 */
@RestController
@RequestMapping("/inventory")
public class InventoryController {
    @Autowired
    private InventoryService inventoryService;

    // 获取所有库存信息
    @PostMapping("/listInventory")
    public R listInventory(Integer currentPage,Integer pageSize,@RequestBody KeyboardVO keyboardVO){
        return inventoryService.listInventory(currentPage, pageSize, keyboardVO);
    }
    // 获取所有详细盘点信息
    @GetMapping("/getInventoryById")
    public R listInventoryDetail(Integer invenid){
        //System.out.println(currentPage1+"!!!"+pageSize1+"!!!!"+invenid);
        return inventoryService.listInventoryDetail(invenid);
    }
    //盘点审核通过，更新状态
    @GetMapping("/updateStateYes")
    @LogAnotation("盘点审核通过")
    public R updateState(Integer invenid,Integer branchid){
        return inventoryService.updateStateYes(invenid,branchid);
    }
    //盘点审核不通过，驳回，状态修改为3
    @GetMapping("/updateStateNo")
    @LogAnotation("盘点审核不通过")
    public R updateStateNo(Integer invenid,String remarks){
        //System.out.println(invenid+"&&&&"+remarks);
        return inventoryService.updateStateNo(invenid,remarks);
    }
    //加载所有报损信息
    @PostMapping("/loadbaosunList")
    public R getOutList(Integer currentPage, Integer pageSize, @RequestBody BaoSunVo baoSunVo){
        return inventoryService.getAllBaoSunGoods(currentPage,pageSize,baoSunVo);
    }
    //检查是否有未审核的盘点单
    @GetMapping("/checkState")
    public R checkState(){
        return inventoryService.checkState();
    }
    //添加盘点
    @PostMapping("/addInventory")
    @LogAnotation("添加盘点")
    public R addInventory(@RequestBody List<AddInventoryVo> listInventoryVo ){
        //System.out.println(listInventoryVo);
        //return null;
        return inventoryService.addInventory(listInventoryVo);
    }

}